package ace.module.account.core.impl.service.authentication.handler;

import ace.module.account.api.model.auth.dto.AuthenticationResult;
import ace.module.account.api.model.auth.input.AuthenticationParams;
import ace.module.account.api.model.auth.input.GenericAuthenticationInput;
import ace.module.account.core.impl.service.authentication.handler.model.input.AuthenticationHandlerContextInput;

/**
 * @author caspar
 * @date 2023/3/16 9:33
 */
public interface AuthenticationHandler<T extends AuthenticationParams> {

  /**
   * 执行认证
   *
   * @param contextInput
   * @return
   */
  AuthenticationResult authentication(AuthenticationHandlerContextInput<T> contextInput);

  /**
   * 认证类型标识
   *
   * @return
   */
  String getGrantType();

  /**
   * json 转换成 业务参数实体
   *
   * @param input {@link GenericAuthenticationInput} json format
   * @return {@link GenericAuthenticationInput} 的业务参数
   */
  T convert(String input);
}
